package com.aqielife.demo.dao;

import com.aqielife.demo.entity.UserNode;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @author aqie
 * @date 2022/02/05 21:45
 * @desc
 */
@Repository
public interface UserRepository extends Neo4jRepository<UserNode,Long> {
  //    @Query("MATCH (n:User) RETURN n ")
//    List<UserNode> getUserNodeList();

//    @Query("create (n:User{name:{name},age:{age},sex:{sex}}) RETURN n ")
//    UserNode addUserNode(@Param("name") String name, @Param("age")int age, @Param("sex") String sex);

  @Query("MATCH (n) WHERE id(n) = :#{#userNode.nodeId} SET n.name = :#{#userNode.name},n.age = :#{#userNode.age},n.sex = :#{#userNode.sex} RETURN n")
  UserNode updateByNode(@Param("userNode") UserNode userNode);
}
